package com.hbnu.collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author kittychen
 * @since 2025-10-14 15:45
 */
public class CollectionsDemo {

    public static void main(String[] args) {
        List<String> arrayList = new ArrayList<>();

        arrayList.add("element7");
        arrayList.add("element2");
        arrayList.add("element1");
        arrayList.add("element5");
        System.out.println(arrayList);

        Collections.addAll(arrayList,"element3","element4","element6");
        System.out.println(arrayList);

        Collections.sort(arrayList);
        System.out.println(arrayList);

        Collections.reverse(arrayList);  // 反转顺序
        System.out.println(arrayList);

        Collections.shuffle(arrayList);  // 随机打乱顺序
        System.out.println(arrayList);

    }
}
